package srm511;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Zoo {
    public long theCount(int[] answers) {
        List<Integer> v1 = new ArrayList<Integer>();
        List<Integer> v2 = new ArrayList<Integer>();
        Arrays.sort(answers);
        v1.add(answers[0]);
        for (int i = 1; i < answers.length; i++) {
            if (answers[i - 1] == answers[i])
                v2.add(answers[i]);
            else
                v1.add(answers[i]);
        }
        int val = 0;
        for (int i = 0; i < v1.size(); i++) {
            if (v1.get(i) != i) return 0;
        }
        for (int i = 0; i < v2.size(); i++) {
            if (v2.get(i) != i) return 0;
        }
        int min = Math.min(v1.size(), v2.size());
        if (v1.size() != v2.size()) min++;
        return 1L << min;
    }
}